import { ECSEntity } from 'db://app-game/libs/ecs/ECSEntity';
import BTConditional from 'db://app-game/libs/math/behavior-tree/base/BTConditional';
import { NodeStatus } from 'db://app-game/libs/math/behavior-tree/enum';
import { CircleModelMonitorComp } from '../../ecs/base/model/CircleModelMonitorComp';

/**
 * 圆形监控范围
 *
 * 1. 创建圆形监控范围
 * 2. 获取碰撞列表
 * 3. 判断碰撞列表是否为空
 * 4. 如果碰撞列表不为空，则返回成功
 * 5. 如果碰撞列表为空，则返回失败
 */
export default class ConditionalCircleMonitor extends BTConditional {
  onUpdate(entity: ECSEntity): NodeStatus {
    const monitorData = entity.get(CircleModelMonitorComp);
    const colliderList = monitorData.colliderList;
    if (colliderList.length > 0) {
      return NodeStatus.Success;
    }
    return NodeStatus.Failure;
  }
}
